package uk.ac.aber.Blockmation;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import uk.ac.aber.Blockmation.Actions.ActionAboutDialog;
import uk.ac.aber.Blockmation.Actions.ActionClearFrame;
import uk.ac.aber.Blockmation.Actions.ActionCopyFrame;
import uk.ac.aber.Blockmation.Actions.ActionDeleteFrame;
import uk.ac.aber.Blockmation.Actions.ActionExportFrame;
import uk.ac.aber.Blockmation.Actions.ActionFileExit;
import uk.ac.aber.Blockmation.Actions.ActionImportImage;
import uk.ac.aber.Blockmation.Actions.ActionInsertFrame;
import uk.ac.aber.Blockmation.Actions.ActionJumpNextFrame;
import uk.ac.aber.Blockmation.Actions.ActionJumpPreviousFrame;
import uk.ac.aber.Blockmation.Actions.ActionJumpToEnd;
import uk.ac.aber.Blockmation.Actions.ActionJumpToStart;
import uk.ac.aber.Blockmation.Actions.ActionLoadProject;
import uk.ac.aber.Blockmation.Actions.ActionNewProject;
import uk.ac.aber.Blockmation.Actions.ActionSaveProject;
import uk.ac.aber.Blockmation.Actions.ActionSaveProjectAs;


/**
 * Contructs the MenuBar, Menus and MenuItems
 * @author tom
 */

public class OurMenu
{
    //Where the GUI is created:
    JMenuBar menuBar;
    JMenu fileMenu;
    JMenu frameMenu;
    JMenu helpMenu;
    JMenuItem menuItem;
    private MainFrame mainFrame;

    public OurMenu(MainFrame mainFrame)
    {
        super();
        this.mainFrame = mainFrame;
    }

    public JMenuBar getOurMenu()
    {
        //creating the menu bar
        menuBar = new JMenuBar();

        //making the first menu
        fileMenu = new JMenu("File");
        menuBar.add(fileMenu);

        //adding menu items to menu 1, file etc, menu items should have mneumonic key accessabilty 
        ActionNewProject actionNewProject = new ActionNewProject(mainFrame);
        menuItem = new JMenuItem(actionNewProject);
        fileMenu.add(menuItem);

        ActionLoadProject actionLoadProject = new ActionLoadProject(mainFrame);
        menuItem = new JMenuItem(actionLoadProject);
        fileMenu.add(menuItem);
        
        ActionSaveProject actionSaveProject = new ActionSaveProject(mainFrame);
        menuItem = new JMenuItem(actionSaveProject);
        fileMenu.add(menuItem);
        
        ActionSaveProjectAs actionSaveProjectAs = new ActionSaveProjectAs(mainFrame);
        menuItem = new JMenuItem(actionSaveProjectAs);
        fileMenu.add(menuItem);

        fileMenu.addSeparator();

        ActionFileExit actionFileExit = new ActionFileExit(mainFrame);
        menuItem = new JMenuItem(actionFileExit);
        fileMenu.add(menuItem);

        //Build second menu in the menu bar.
        frameMenu = new JMenu("Frame");
        menuBar.add(frameMenu);
        
        //adding menu items to menu 2, frame interaction etc
        
        
        ActionClearFrame actionClearFrame = new ActionClearFrame(mainFrame);
        menuItem = new JMenuItem(actionClearFrame);
        frameMenu.add(menuItem);
        
        ActionInsertFrame actionInsertFrame = new ActionInsertFrame(mainFrame);
        menuItem = new JMenuItem(actionInsertFrame);
        frameMenu.add(menuItem);

        ActionCopyFrame actionCopyFrame = new ActionCopyFrame(mainFrame);
        menuItem = new JMenuItem(actionCopyFrame);
        frameMenu.add(menuItem);

        ActionDeleteFrame actionDeleteFrame = new ActionDeleteFrame(mainFrame);
        menuItem = new JMenuItem(actionDeleteFrame);
        frameMenu.add(menuItem);

        frameMenu.addSeparator();

        ActionJumpNextFrame actionJumpNextFrame = new ActionJumpNextFrame(mainFrame,true);
        menuItem = new JMenuItem(actionJumpNextFrame);
        frameMenu.add(menuItem);

        ActionJumpPreviousFrame actionJumpPreviousFrame = new ActionJumpPreviousFrame(mainFrame,true);
        menuItem = new JMenuItem(actionJumpPreviousFrame);
        frameMenu.add(menuItem);

        ActionJumpToStart actionJumpToStart = new ActionJumpToStart(mainFrame);
        menuItem = new JMenuItem(actionJumpToStart);
        frameMenu.add(menuItem);

        //this one contains code for icons on menuItems
        ActionJumpToEnd actionJumpToEnd = new ActionJumpToEnd(mainFrame);
        menuItem = new JMenuItem(actionJumpToEnd);
        frameMenu.add(menuItem);
        
        frameMenu.addSeparator();
        
        ActionImportImage actionImportImage = new ActionImportImage(mainFrame);
        menuItem = new JMenuItem(actionImportImage);
        frameMenu.add(menuItem);    
        
        ActionExportFrame actionExportFrame = new ActionExportFrame(mainFrame);
        menuItem = new JMenuItem(actionExportFrame);
        frameMenu.add(menuItem); 
        
        
        //Build third menu in the menu bar.
        helpMenu = new JMenu("Help");
        menuBar.add(helpMenu);
        ////adding menu items to menu 3
        ActionAboutDialog actionAboutDialog = new ActionAboutDialog(mainFrame);
        menuItem = new JMenuItem(actionAboutDialog);
        helpMenu.add(menuItem);
        
        
        return menuBar;
    } ///end bracket of menu
} ////end bracket of class
